# -*-coding:utf-8-*-
# Created by ccp on 2018/4/25.

# 斐波那契数列

# ｛0，1，1，2，3，5，8，13，。。。｝

import time


def fibs(num):
    result = [0, 1]
    for i in range(num - 2):
        result.append(result[-1] + result[-2])
    return result


def main():
    fibsList = fibs(20)
    print(fibsList)
    bobj = open('fibonacci.txt', 'w+')
    for index, fib in enumerate(fibsList):
        print("元素-", index, ":", fibsList[index])
        bobj.write(u"元素-"+str(index)+":"+str(fib)+"\n")
    bobj.close()


if __name__ == '__main__':
    main()
